package com.rxmvp.rxmvpdemo.utils;

import android.content.Context;
import android.widget.Toast;

import com.rxmvp.rxmvpdemo.App;

/**
 * 作者： huangRZ on 2017/1/21. 15:04
 * 邮箱：917647409@qq.com
 */
public class ToastUtil {

    private static Toast mToast;

    public static void toastLong(Context ct, String msg) {
        Toast.makeText(ct, msg, Toast.LENGTH_LONG).show();
    }

    public static void toastShort(Context ct, String msg) {
        Toast.makeText(ct, msg, Toast.LENGTH_SHORT).show();
    }

    public static void toastLong(Context ct, int StringId) {
        Toast.makeText(ct, StringId, Toast.LENGTH_LONG).show();
    }

    public static void toastShort(Context ct, int StringId) {
        Toast.makeText(ct, StringId, Toast.LENGTH_SHORT).show();
    }

//    public static void toastCenter(Context context, String msg){
//        new CenterToast(context, msg).showDatePicker();
//    }
//    public static void toastCenter(Context context, int StringId){
//        new CenterToast(context, context.getString(StringId)).showDatePicker();
//    }
//    public static void showToastLongDebug(Context context, String msg) {
//        if (!BuildConfig.ISOPEN)
//            Toast.makeText(context, "debug:" + msg, Toast.LENGTH_LONG).showDatePicker();
//    }
//
//    public static void showToastShortDebug(Context context, String msg) {
//        if (!BuildConfig.ISOPEN)
//            Toast.makeText(context, "debug:" + msg, Toast.LENGTH_SHORT).showDatePicker();
//    }

    public static void showToast(String msg){
        if (mToast == null) {
            mToast = Toast.makeText(App.getApp(), msg, Toast.LENGTH_SHORT);
        } else {
            mToast.setText(msg);
        }
        mToast.show();
    }

    public static void showLongToast(String msg){
        if (mToast == null) {
            mToast = Toast.makeText(App.getApp(), msg, Toast.LENGTH_LONG);
        } else {
            mToast.setText(msg);
        }
        mToast.show();
    }
}
